package com.qf.ayc.income.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.ayc.income.entity.Income;
import com.qf.ayc.income.mapper.IncomeMapper;
import com.qf.ayc.income.service.IIncomeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author BeautyFairy
 * @since 2024-02-22
 */
@Service
public class IncomeServiceImpl extends ServiceImpl<IncomeMapper, Income> implements IIncomeService {

    @Autowired
    private IncomeMapper incomeMapper;
    @Override
    public void add(Income income) {
        incomeMapper.insert(income);

    }

    //总收入
    @Override
    public List<Integer> getlist() {
        QueryWrapper<Income> wrapper = new QueryWrapper<>();
        ArrayList<Integer> incomes1 = new ArrayList<>();
        //每条数据  但是我们要money的所有数据
        List<Income> incomes = incomeMapper.selectList(wrapper);
        //获取到money所有数
        for (Income income : incomes) {
            incomes1.add( income.getMoneyamount());
        }
        return incomes1;
    }

}
